/* 
 * Retrieve all calendars 
 */

// Create the calendar service object
var calendarService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');

// The default "allcalendars" feed is used to retrieve a list of all 
// calendars (primary, secondary and subscribed) of the logged-in user
var feedUri = 'http://www.google.com/calendar/feeds/default/allcalendars/full';

// The callback method that will be called when getAllCalendarsFeed() returns feed data
var callback = function(result) {

  // Obtain the array of CalendarEntry
  var entries = result.feed.entry;
  
  for (var i = 0; i < entries.length; i++) {
    var calendarEntry = entries[i];
    var calendarTitle = calendarEntry.getTitle().getText();
    PRINT('Calendar title = ' + calendarTitle);
  }
}

// Error handler to be invoked when getAllCalendarsFeed() produces an error
var handleError = function(error) {
  PRINT(error);
}

// Submit the request using the calendar service object
calendarService.getAllCalendarsFeed(feedUri, callback, handleError);
